package com.flyiu.data.consistency;

import java.time.LocalDateTime;
import java.time.temporal.TemporalAccessor;
import java.util.Optional;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.data.auditing.DateTimeProvider;
import org.springframework.scheduling.annotation.EnableScheduling;

@Configuration
//@ComponentScan
@EnableScheduling
//@EnableAsync(proxyTargetClass=true)
//@EnableAspectJAutoProxy(proxyTargetClass=true,exposeProxy=true)
public class DataConsistencyApp {
    
    @ConditionalOnMissingBean
	@Bean
	public DateTimeProvider auditDate() {
		return new DateTimeProvider() {
		    @Override
            public Optional<TemporalAccessor> getNow() {
                return Optional.of(LocalDateTime.now());
            }
		};
	}
}
